Skip to content

[daehyun99] WEEK 07 Solutions - #2801

Open
daehyun99 wants to merge 5 commits into
DaleStudy:mainfrom
daehyun99:W7
Open

[daehyun99] WEEK 07 Solutions#2801
daehyun99 wants to merge 5 commits into
DaleStudy:mainfrom
daehyun99:W7

Conversation

@daehyun99

@daehyun99 daehyun99 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

longest-substring-without-repeating-characters/daehyun99.py
class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        l = 0
        seen = set()
        longest = 0

        for c in s:
            if c not in seen:
                seen.add(c)
                longest = max(longest, len(seen))
            else:
                while c in seen:
                    seen.remove(s[l])
                    l += 1
                seen.add(c)
        return longest
  • 패턴: Two Pointers, Hash Map / Hash Set, Sliding Window
  • 설명: 문자열에서 중복 문자를 제거하며 최장 부분 문자열 길이를 구하는 방식으로, 좌측 포인터와 우측 포인터처럼 창을 이동시키며 부분 문자열을 관리한다. 집합으로 현재 창의 문자를 추적하고 중복 시 창을 좁혀 재진입을 허용한다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(min(n, k))

피드백: seen 집합과 포인터 l을 사용해 중복 문자가 나오면 왼쪽을 제거하며 부분 문자열 길이를 갱신한다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

@dalestudy

dalestudy Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📊 daehyun99 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
longest-substring-without-repeating-characters Medium ✅ 의도한 유형
number-of-islands Medium ✅ 의도한 유형
reverse-linked-list Easy ✅ 의도한 유형
set-matrix-zeroes Medium ✅ 의도한 유형
unique-paths Medium ✅ 의도한 유형

누적 학습 요약

  • 풀이한 문제: 29 / 75개
  • 이번 주 유형 일치율: 100% (5문제 중 5문제 일치)

문제 풀이 현황

카테고리 진행도 완료
Array ■■■■■■□ 8 / 10 (Medium 5, Easy 3)
Dynamic Programming ■■■■□□□ 6 / 11 (Easy 1, Medium 5)
Matrix ■■■■□□□ 2 / 4 (Medium 2)
String ■■■■□□□ 5 / 10 (Medium 2, Easy 3)
Heap ■■□□□□□ 1 / 3 (Medium 1)
Tree ■■□□□□□ 4 / 14 (Medium 3, Easy 1)
Binary ■□□□□□□ 1 / 5 (Easy 1)
Linked List ■□□□□□□ 1 / 6 (Easy 1)
Graph ■□□□□□□ 1 / 8 (Medium 1)
Interval □□□□□□□ 0 / 5 ← 아직 시작 안 함

🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다.

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 1,856 233 2,089 $0.000186

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

number-of-islands/daehyun99.py
# Time: O(M * N)
# Space: O(M * N)
class Solution:
    def numIslands(self, grid: List[List[str]]) -> int:
        h = len(grid)
        w = len(grid[0])
        count = 0
        for i in range(h):
            for j in range(w):
                if grid[i][j] == "1":
                    stack = []
                    stack.append([i, j])
                    while len(stack) > 0 :
                        x, y = stack.pop()

                        grid[x][y] = "0"
                        if x > 0 and grid[x-1][y] == "1":
                            stack.append([x-1, y])
                        if x + 1 < h and grid[x+1][y] == "1":
                            stack.append([x+1, y])
                        if y > 0 and grid[x][y-1] == "1":
                            stack.append([x, y-1])
                        if y + 1 < w and grid[x][y+1] == "1":
                            stack.append([x, y+1])
                    count += 1
        return count
  • 패턴: Depth-First Search, Backtracking
  • 설명: 섬의 연결 여부를 탐색하기 위해 스택으로 DFS 방식으로 인접 영역을 탐색합니다. 한 번 방문한 노드를 표시하여 전체 섬을 탐색하고 개수를 증가시키는 방식이 DFS 특징과 일치합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(M * N) O(h * w)
Space O(M * N) O(h * w)

피드백: grid를 순회하며 1인 칸마다 DFS/BFS로 연결된 영역을 탐색한다.

개선 제안: 현재 구현이 적절해 보입니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

reverse-linked-list/daehyun99.py
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
# Time: O(N)
# Space: O(1)
class Solution:
    def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
        if head is None:
            return head
        pointer = head
        left = None
        while pointer.next is not None:
            right = pointer.next
            pointer.next = left
            left = pointer
            pointer = right
        pointer.next = left
        return pointer
  • 패턴: Two Pointers, Linked List
  • 설명: 주어진 코드는 단일 연결 리스트를 역방향으로 순회하며 포인터를 앞뒤로 바꿔 연결 방향을 뒤집는 구조로, 두 포인터를 활용한 순회 방식이 핵심 패턴입니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(N) O(n)
Space O(1) O(1)

피드백: 커서 포인터를 이용해 노드를 반전시키며 순차적으로 앞 노드를 가리키게 한다.

개선 제안: 현재 구현이 적절해 보입니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

set-matrix-zeroes/daehyun99.py
class Solution:
    def setZeroes(self, matrix: List[List[int]]) -> None:
        row = set()
        col = set()

        for i in range(len(matrix)):
            if 0 in matrix[i]:
                row.add(i)
                for j in range(len(matrix[0])):
                    if matrix[i][j] == 0:
                        col.add(j)

        for i in row:
            matrix[i] = [0] * len(matrix[0])
        
        for i in range(len(matrix)):
            if i in row:
                continue
            for j in range(len(matrix[0])):
                if j in col:
                    matrix[i][j] = 0
  • 패턴: Hash Map / Hash Set, Greedy
  • 설명: 행과 열의 제로 위치를 저장하기 위해 해시 세트를 사용하고, 그 정보를 바탕으로 행 전체를 0으로 만들고 나머지 열도 0으로 설정하는 방식으로 필요한 위치를 결정합니다. 직접적인 최적화보다는 저장 후 일괄 수정하는 패턴입니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(m * n)
Space O(m + n)

피드백: 먼저 0이 존재하는 행/열을 수집하고, 두 번째 순회에서 0으로 설정한다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Comment thread unique-paths/daehyun99.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

unique-paths/daehyun99.py
class Solution:
    def uniquePaths(self, m: int, n: int) -> int:
        matrix = [[0] * n for _ in range(m)]
        matrix[0][0] += 1

        for x in range(m):
            for y in range(n):
                if x == 0 and y == 0:
                    continue
                elif x == 0:
                    matrix[x][y] += matrix[x][y-1]
                elif y == 0:
                    matrix[x][y] += matrix[x-1][y]
                else:
                    matrix[x][y] += (matrix[x][y-1] + matrix[x-1][y])
        return matrix[m-1][n-1]
  • 패턴: Dynamic Programming
  • 설명: 2차원 DP 배열을 이용해 좌하에서 우상로의 경로 개수를 누적 합으로 구하는 전형적인 DP 문제 풀이이며, 이전 위치의 값을 활용해 현재 값을 계산한다.

📊 시간/공간 복잡도 분석

복잡도
Time O(m * n)
Space O(m * n)

피드백: 2차원 DP 배열을 사용해 위/왼쪽의 경로 수를 합산한다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

@dahyeong-yun
dahyeong-yun self-requested a review August 7, 2026 12:38
longest = 0

for c in s:
if c not in seen:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 로직이 하단의 while과 겹치지 않을까요?
중복 로직을 제거할수 있을것 같아요!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 문제는 조금 더 코드 라인 수를 확 줄일수 있는 문제에요!
시도 한번 해보시는것도 좋겠어요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants